#! /bin/bash # employ bash shell
set -e
#---------------------------------------------
		##curl -O -L http://www.nasm.us/pub/nasm/releasebuilds/2.14.02/nasm-2.14.02.tar.bz2
tar jxvf ./nasm-2.14.02.tar.bz2 
cd ./nasm-2.14.02
./autogen.sh
mkdir  -p install
./configure  --prefix   $(pwd)/install 
make install
set +e
sudo mv  /usr/bin/nasm /usr/bin/nasm.old
set -e
sudo ln -s $(pwd)/install/bin/nasm /usr/bin/
set +e
sudo mv  /usr/bin/ndisasm /usr/bin/ndisasm.old
set -e
sudo ln -s $(pwd)/install/bin/ndisasm /usr/bin/
cd ..
#---------------------------------------------
		##git clone https://github.com/mirror/x264.git
unzip ./x264.zip
cd ./x264
mkdir -p  install
./configure --enable-static --enable-shared  --prefix=$(pwd)/install  
make
make install

sudo rm /usr/bin/nasm
set +e
sudo mv /usr/bin/nasm.old  /usr/bin/nasm 
set -e
sudo rm /usr/bin/ndisasm
set +e
sudo mv /usr/bin/ndisasm.old  /usr/bin/ndisasm 


sudo mv  /usr/include/x264.h /usr/include/x264.h.old
set -e
sudo ln -s $(pwd)/install/include/x264.h /usr/include/
set +e
sudo mv  /usr/include/x264_config.h /usr/include/x264_config.h.old
set -e
sudo ln -s $(pwd)/install/include/x264_config.h /usr/include/
set +e
sudo mv  /usr/lib/libx264.so.161 /usr/lib/libx264.so.161.old
set -e
sudo ln -s $(pwd)/install/lib/libx264.so.161 /usr/lib/
set +e
sudo mv  /usr/lib/libx264.so /usr/lib/libx264.so.old
set -e
sudo ln -s $(pwd)/install/lib/libx264.so /usr/lib/
set +e
sudo mv  /usr/lib/libx264.a /usr/lib/libx264.a.old
set -e
sudo ln -s $(pwd)/install/lib/libx264.a /usr/lib/
cd ..
#---------------------------------------------
		##wget https://ffmpeg.org/releases/ffmpeg-4.1.3.tar.bz2
tar jxvf ./ffmpeg-4.1.3.tar.bz2
cd ./ffmpeg-4.1.3 
mkdir -p  install
./configure --enable-shared --enable-gpl --enable-libx264 --disable-x86asm   --prefix=$(pwd)/install  
make
make install

sudo rm /usr/include/x264.h
set +e
sudo mv /usr/include/x264.h.old  /usr/include/x264.h 
set -e
sudo rm /usr/include/x264_config.h
set +e
sudo mv /usr/include/x264_config.h.old  /usr/include/x264_config.h
set -e
sudo rm /usr/lib/libx264.so.161
set +e
sudo mv /usr/lib/libx264.so.161.old  /usr/lib/libx264.so.161
set -e
sudo rm /usr/lib/libx264.so
set +e
sudo mv /usr/lib/libx264.so.old  /usr/lib/libx264.so
set -e
sudo rm /usr/lib/libx264.a
set +e
sudo mv /usr/lib/libx264.a.old  /usr/lib/libx264.a
set -e
cd ..
#---------------------------------------------
#export LD_LIBRARY_PATH=/usr/local/lib/
#---------------------------------------------


